import Vue from 'vue'
import { get, post } from './http'
import Qs from 'qs'
console.log(get, post)

const commonUrl = '/report-led-api/rest-api/v5'
const vueProto = Vue.prototype

vueProto.commonApi = {
  // 加载组织树
  loadOrganTree: () => post('/common-api/rest-api/v5/organ/tree/loadOrganTree', Qs.stringify({})),
  // 组织树按关键字查询
  queryTreeByKey: (keywords, exclusionOrgTypes) => {
    if (exclusionOrgTypes === 'exclusionOrgTypes') {
      exclusionOrgTypes = '2,3,4,5,7,9'
    }
    return post('/common-api/rest-api/v5/organ/tree/queryTreeByKey', Qs.stringify({ keywords, exclusionOrgTypes }))
  },
  // 按ID查询组织树
  querySubTreeById: (id, exclusionOrgTypes) => {
    if (exclusionOrgTypes === 'exclusionOrgTypes') {
      exclusionOrgTypes = '2,3,4,5,7,9'
    }
    return post('/common-api/rest-api/v5/organ/tree/querySubTreeById', Qs.stringify({ id, exclusionOrgTypes }))
  },
  // 天气接口
  getWeather: () => get(commonUrl + '/environment/getLocalWeatherInfo'),
  // 获取用户有哪些模块
  getModuleList: () => get(commonUrl + '/layout/getModuleList'),
  // 获取公司页面配置
  getPageConfig: options => get(commonUrl + '/layout/getPageCfgInfo', options),
  // 获取公司页面配置
  getPageCfgInfoByUserId: options => get(commonUrl + '/layout/getPageCfgInfoByUserId', options),
  // 保存配置
  savePageConfig: options => post(commonUrl + '/layout/savePageCfgInfo', options),
  // 获取organId对应的名字
  getOrganAlisaName: options => post(commonUrl + '/organ/getOrganAlisaName', options),
  // 保存公司别名
  saveOrganAlisaName: options => post(commonUrl + '/organ/saveOrganAlisaName', options),
  // 登录
  login: options => post('/uhome-portal/portal/auth/login.json', Qs.stringify(options))
}

// 地图数据
vueProto.mapApi = {
  // 全国省份地图
  getProvinceList: options => post(commonUrl + '/organ/getProvinceList', options),
  // 省内城市
  getProvinceData: options => post(commonUrl + '/organ/getCityList', options),
  // 市内区地图
  getCityData: options => post(commonUrl + '/organ/getAreaList', options)
}

// 基础信息
vueProto.basicInforMationApi = {
  // 基础信息
  getInformation: options => post(commonUrl + '/organ/getOrganBasicInfo', options),
  // 项目信息
  getOrganCommunityTypeList: options => post(commonUrl + '/organ/getOrganCommunityTypeList', options),
  // 房屋状态
  getOrganHouseTypeListByMid: options => post(commonUrl + '/organ/getOrganHouseTypeListByMid', options)
}

// 存量资产概况
vueProto.stockAssetsApi = {
  // 存量资产概况
  getStockAssetsSituationList: options => get(commonUrl + '/assetManger/getStockAssetsSituationList', options),
  // 资源处理概况
  getAssetsDisposalSituationList: options => get(commonUrl + '/assetManger/getAssetsDisposalSituationList', options),
  // 存量资产分布
  getStockAssetsDistributionList: options => get(commonUrl + '/assetManger/getStockAssetsDistributionList', options),
  // 资产处理分布
  getAssetsDisposalDistributionList: options => get(commonUrl + '/assetManger/getAssetsDisposalDistributionList', options)
}

// 园区
vueProto.parkApi = {
  // 园区概况
  parkSummary: options => post(commonUrl + '/parkVisit/parkSummary', options),
  // 园区环境指数
  // temperature: options => post(commonUrl + '/parkVisit/temperature', options),
  // 园区环境指数
  temperature: options => post('http://webapi.eegrid.com/realdata/get?AccessToken=42CD23102EF55F4BC3ED931C8DAA6058', Qs.stringify(options)),
  // 园区服务体系
  businessServiceSummary: options => post(commonUrl + '/parkVisit/businessServiceSummary', options),
  // 园区服务趋势
  businessServiceLastYearTrend: options => post(commonUrl + '/parkVisit/businessServiceLastYearTrend', options),
  // 园区企业孵化，人才引进，企业分布，企业收入规模，纳税规模分布，专利分布
  ratio: options => post(commonUrl + '/parkVisit/ratio', options),
  // 客户满意度
  getSatisfiedRateInfo: options => post(commonUrl + '/customer/getSatisfiedRateInfo', options)
}

// 2.0版本的旧模块接口
vueProto.orderApi = {
  // 服务满意度情况信息
  getSatisfiedRateInfo: options => post(commonUrl + '/customer/getSatisfiedRateInfo', options),
  // 获取投诉信息
  getComplainCountInfo: options => post(commonUrl + '/customer/getComplainCountInfo', options),
  // 客服工单
  getOrderDealInfo: options => post(commonUrl + '/order/getOrderDealInfo', options),
  // 获取投诉渠道分布
  getComplainChannelList: options => post(commonUrl + '/customer/getComplainChannelList', options),
  // 获取投诉类型分布
  getComplainTypeList: options => post(commonUrl + '/customer/getComplainTypeList', options),
  // 客户投诉同比环比
  getComplainYearOnYearList: options => post(commonUrl + '/customer/getComplainYearOnYearList', options),
  // 客户满意度同比环比
  getSatisfiedRateYearOnYearList: options => post(commonUrl + '/customer/getSatisfiedRateYearOnYearList', options),
  // 客户投诉分公司对比
  getBranchComplainCountList: options => post(commonUrl + '/customer/getBranchComplainCountList', options),
  // 客户满意度分公司对比
  getBranchSatisfiedRateList: options => post(commonUrl + '/customer/getBranchSatisfiedRateList', options),
  // 本月工单渠道
  getOrderChannelList: options => post(commonUrl + '/order/getOrderChannelList', options),
  // 本月工单类型
  getOrderTypeList: options => post(commonUrl + '/order/getOrderTypeList', options),
  // 工单数量趋势
  getOrderYearOnYearList: options => post(commonUrl + '/order/getOrderYearOnYearList', options),
  // 响应及时率趋势
  getDispTimelyRateYearOnYearList: options => post(commonUrl + '/order/getDispTimelyRateYearOnYearList', options),
  // 结单率趋势
  getOverRateYearOnYearList: options => post(commonUrl + '/order/getOverRateYearOnYearList', options),
  // 工单数量对比
  getBranchOrderCountList: options => post(commonUrl + '/order/getBranchOrderCountList', options),
  // 响应及时率对比
  getBranchDispTimelyRateList: options => post(commonUrl + '/order/getBranchDispTimelyRateList', options),
  // 结单率对比
  getBranchOverRateList: options => post(commonUrl + '/order/getBranchOverRateList', options)
}

// 物业收费
vueProto.propertyApi = {
  // 物业收费
  getOperateIncomeInfo: options => post(commonUrl + '/organFee/getOperateIncomeInfo', options),
  // 收缴率
  getPropertyFeeCaptureInfo: options => post(commonUrl + '/organFee/getPropertyFeeCaptureInfo', options),
  // 本月收费渠道
  getPropertyFeeChannel: options => post(commonUrl + '/organFee/getPropertyFeeChannel', options),
  // 本月实收科目
  getPropertyFeeDistribution: options => post(commonUrl + '/organFee/getPropertyFeeDistribution', options),
  // 实收金额趋势
  getPropertyFeeYearOnYear: options => post(commonUrl + '/organFee/getPropertyFeeYearOnYear', options),
  // 欠费金额趋势
  getPropertArrearageYearOnYear: options => post(commonUrl + '/organFee/getPropertArrearageYearOnYear', options),
  // 收缴率趋势
  getPropertPayRateYearOnYear: options => post(commonUrl + '/organFee/getPropertPayRateYearOnYear', options),
  // 实收金额对比
  getBranchPropertyFee: options => post(commonUrl + '/organFee/getBranchPropertyFee', options),
  // 欠费金额对比
  getBranchPropertyArrearage: options => post(commonUrl + '/organFee/getBranchPropertyArrearage', options),
  // 收缴率对比
  getBranchPayRate: options => post(commonUrl + '/organFee/getBranchPayRate', options)
}

// 安防管控
vueProto.controlApi = {
  // 巡更完成率
  getPatrolMonthInfo: options => post(commonUrl + '/safeDefend/getPatrolMonthInfo', options),
  // 手机开门
  getOpenDoorInfo: options => post(commonUrl + '/safeDefend/getOpenDoorInfo', options),
  // 访客数量趋势
  getVisitorRecordContrast: options => post(commonUrl + '/safeDefend/getVisitorRecordContrast', options),
  // 手机开门趋势
  getOpenDoorRecordContrast: options => post(commonUrl + '/safeDefend/getOpenDoorRecordContrast', options),
  // 巡更完成率
  getPatrolFinishRateContrast: options => post(commonUrl + '/safeDefend/getPatrolFinishRateContrast', options),
  // 巡更及时率
  getPatrolTimelyRateContrast: options => post(commonUrl + '/safeDefend/getPatrolTimelyRateContrast', options),
  // 巡更指标对比
  getPatrolRateContrastByCompany: options => post(commonUrl + '/safeDefend/getPatrolRateContrastByCompany', options),
  // 巡更设置对比
  getPatrolSettingContrastByCompany: options => post(commonUrl + '/safeDefend/getPatrolSettingContrastByCompany', options)
}

// 设备信息
vueProto.equipmentApi = {
  // 获取能耗信息
  getHydropowerEnergyInfo: options => post(commonUrl + '/equipment/getHydropowerEnergyInfo', options),
  // 获取设备信息
  getEquipInspectionMaintainInfo: options => post(commonUrl + '/equipment/getEquipInspectionMaintainInfo', options),
  // 获取水能信息
  getWaterConsumptionContrast: options => post(commonUrl + '/equipment/getWaterConsumptionContrast', options),
  // 获取电能信息
  getElectricityConsumptionContrast: options => post(commonUrl + '/equipment/getElectricityConsumptionContrast', options),
  // 巡检完成率
  getDtFinishRateByType: options => post(commonUrl + '/equipment/getDtFinishRateByType', options),
  // 获取巡检及时率
  getDtTimelyRateByType: options => post(commonUrl + '/equipment/getDtTimelyRateByType', options),
  // 保养完成率
  // getDtFinishRateByType: options => post(commonUrl + '/equipment/getDtFinishRateByType', options),
  // 保养及时率
  // getDtTimelyRateByType: options => post(commonUrl + '/equipment/getDtTimelyRateByType', options),
  // 水电能耗分公司对比
  getWaterAndElectricityConsumptionContrastByCompany: options => post(commonUrl + '/equipment/getWaterAndElectricityConsumptionContrastByCompany', options),
  // 设备巡检分公司对比
  getDtRateByTypeAndCompany: options => post(commonUrl + '/equipment/getDtRateByTypeAndCompany', options)
  // 设备保养分公司对比
  // getDtRateByTypeAndCompany: options => post(commonUrl + '/equipment/getDtRateByTypeAndCompany', options)
}

// 仓库信息
vueProto.warehouseApi = {
  // 仓库基础信息
  getWarehouseBasicInfo: options => post(commonUrl + '/warehouse/getWarehouseBasicInfo', options),
  // 库存信息
  getStockCountInfo: options => post(commonUrl + '/warehouse/getStockCountInfo', options),
  // 出货量
  getOutCountInfo: options => post(commonUrl + '/warehouse/getOutCountInfo', options),
  // 出库趋势
  getOutQuantityContrast: options => post(commonUrl + '/warehouse/getOutQuantityContrast', options),
  // 库存趋势
  getStockQuantityContrast: options => post(commonUrl + '/warehouse/getStockQuantityContrast', options),
  // 出库对比
  getOutQuantityContrastByCompany: options => post(commonUrl + '/warehouse/getOutQuantityContrastByCompany', options),
  // 库存对比
  getStockQuantityContrastByCompany: options => post(commonUrl + '/warehouse/getStockQuantityContrastByCompany', options)
}

// 员工考勤
vueProto.staffApi = {
  // 员工考勤
  getDayCheckingInfo: options => post(commonUrl + '/employee/getDayCheckingInfo', options),
  // 全勤率趋势
  getNormalRate: options => post(commonUrl + '/employee/getNormalRate', options),
  // 请假天数趋势
  getLeaveDay: options => post(commonUrl + '/employee/getLeaveDay', options),
  // 全勤率对比
  getBranchNormalRate: options => post(commonUrl + '/employee/getBranchNormalRate', options),
  // 请假天数对比
  getBranchLeaveDay: options => post(commonUrl + '/employee/getBranchLeaveDay', options)
}

// 设备信息
vueProto.equipmentInfoApi = {
  // 取组织机构最近一年设备巡检保养异常率，及时率，完成率对比
  fieldContrastByMonth: options => post(commonUrl + '/equipment/fieldContrastByMonth', options),
  // 获取设备当月数据
  presentMonth: options => post(commonUrl + '/equipment/presentMonth', options),
  // 设备巡检/保养指标年度对比
  getDtFieldContrastsByYear: options => post(commonUrl + '/equipment/getDtFieldContrastsByYear', options),
  // 设备巡检/保养分公司对比
  getDtRateByTypeAndCompany: options => post(commonUrl + '/equipment/getDtRateByTypeAndCompany', options)
}

// 巡更分析f
vueProto.patrolApi = {
  // 获取组织机构最近一年巡更保养异常率，及时率，完成率对比
  fieldContrastByMonth: options => post(commonUrl + '/patrol/fieldContrastByMonth', options),
  // 获取巡更当月数据
  presentMonth: options => post(commonUrl + '/patrol/presentMonth', options),
  // 巡更指标年度对比
  getDtFieldContrastsByYear: options => post(commonUrl + '/patrol/getDtFieldContrastsByYear', options),
  // 完成率，及时率，异常率 分公司对比
  getPatrolRateContrastByCompany: options => post(commonUrl + '/safeDefend/getPatrolRateContrastByCompany', options),
  // 巡更设置 分公司对比
  getPatrolSettingContrastByCompany: options => post(commonUrl + '/safeDefend/getPatrolSettingContrastByCompany', options)
}

// 员工报单
vueProto.employeeApi = {
  // 员工当月数据
  presentMonth: options => post(commonUrl + '/order/presentMonth', options),
  // 近一年员工报单趋势
  getServiceOrderInfoByMonth: options => post(commonUrl + '/order/getServiceOrderInfoByMonth', options),
  // 员工报单响应及时率完成率
  getCKHoumePageOrderInfoByMonth: options => post(commonUrl + '/order/getCKHoumePageOrderInfoByMonth', options),
  // 员工报单类型分布
  getTemplateTypeDistribute: options => post(commonUrl + '/order/getTemplateTypeDistribute', options),
  // 员工报单,结单率同比环比
  getServiceOrderInfoByYearOnMonth: options => post(commonUrl + '/order/getServiceOrderInfoByYearOnMonth', options),
  // 员工报单响应及时率同比环比
  getTimeTacheInfoByYearOnMonth: options => post(commonUrl + '/order/getTimeTacheInfoByYearOnMonth', options),
  // 员工报单,结单率 分公司同比
  getServiceOrderInfoByChildNode: options => post(commonUrl + '/order/getServiceOrderInfoByChildNode', options),
  // 员工报单相应及时率 分公司同比
  getTimeTacheInfoByChildNode: options => post(commonUrl + '/order/getTimeTacheInfoByChildNode', options)
}

// 智慧园区，视频监控
vueProto.wisdomParkApi = {
  // 园区整体概况
  summary: options => post(commonUrl + '/sany/hikvision/summary', options),
  // 人员出入详情
  personAccess: options => post(commonUrl + '/sany/hikvision/personAccess', options),
  // 园区车位详情
  carsDetail: options => post(commonUrl + '/sany/hikvision/carsDetail', options),
  // 园区车辆统计
  carsTrend: options => post(commonUrl + '/sany/hikvision/carsTrend', options),
  // 园区监控报警
  personWarnningTrend: options => post(commonUrl + '/sany/hikvision/personWarnningTrend', options),
  // 园区周界报警
  deviceWarnningRatio: options => post(commonUrl + '/sany/hikvision/deviceWarnningRatio', options),
  // 园区能耗
  nowAndLast7Day: options => post(commonUrl + '/energy/nowAndLast7Day', options),
  // 大屏轮播图
  carouselConfig: options => post(commonUrl + '/leadview/carousel/config', options),
  // 海康获取视频 url
  getCameraPreviewURL: options => post(commonUrl + '/sany/hikvision/getCameraPreviewURL', options)
}

// 运营视角
vueProto.operationApi = {
  // 运营概况
  businessBasicSummary: options => post(commonUrl + '/business/businessBasicSummary', options),
  // 园区经营收入
  businessResourceFee: options => post(commonUrl + '/business/businessResourceFee', options),
  // 租金收入概况
  businessLeaseFee: options => post(commonUrl + '/business/businessLeaseFee', options),
  // 园区整体概况
  businessLeaseFeeByMonth: options => post(commonUrl + '/business/businessLeaseFeeByMonth', options),
  // 园区服务体系（内部）
  businessServiceSummary: options => post(commonUrl + '/business/businessServiceSummary', options)
}

const reportCeszUrl = '/report-cesz/rest-api'
// 资产经营概况
vueProto.assetsManagementApi = {
  // 租赁资源概况
  typeDistributed: options => post(reportCeszUrl + '/asset/lease/typeDistributed', options),
  // 目标达成概况
  targetInfo: options => post(reportCeszUrl + '/asset/lease/targetInfo', options),
  // 租金收入趋势
  incomeChange: options => post(reportCeszUrl + '/asset/lease/incomeChange', options),
  // 本年租赁趋势
  leaseChangeByType: options => post(reportCeszUrl + '/asset/lease/leaseChangeByType', options),
  // 本年租赁趋势排名
  topRentedOutResource: options => post(reportCeszUrl + '/asset/lease/topRentedOutResource', options),
  // 本年空置情况
  vacantInfo: options => post(reportCeszUrl + '/asset/lease/vacantInfo', options),
  // 管理主体目标达成
  targetManager: options => post(reportCeszUrl + '/asset/lease/targetManager', options),
  // 本年签约变化
  signedChange: options => post(reportCeszUrl + '/asset/lease/signedChange', options)
}

export default vueProto
